<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>列车数据监测系统</title>


    <style>
        /* Bootstrap 5 CSS */
        :root {
            --bs-blue: #0d6efd;
            --bs-indigo: #6610f2;
            --bs-purple: #6f42c1;
            --bs-pink: #d63384;
            --bs-red: #dc3545;
            --bs-orange: #fd7e14;
            --bs-yellow: #ffc107;
            --bs-green: #198754;
            --bs-teal: #20c997;
            --bs-cyan: #0dcaf0;
            --bs-white: #fff;
            --bs-gray: #6c757d;
            --bs-gray-dark: #343a40;
            --bs-primary: #0d6efd;
            --bs-secondary: #6c757d;
            --bs-success: #198754;
            --bs-info: #0dcaf0;
            --bs-warning: #ffc107;
            --bs-danger: #dc3545;
            --bs-light: #f8f9fa;
            --bs-dark: #212529;
            --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
            --bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
            --bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));
        }

        *,
        *::before,
        *::after {
            box-sizing: border-box;
        }

        @media (prefers-reduced-motion: no-preference) {
            :root {
                scroll-behavior: smooth;
            }
        }

        body {
            margin: 0;
            font-family: var(--bs-font-sans-serif);
            font-size: 1rem;
            font-weight: 400;
            line-height: 1.5;
            color: #212529;
            background-color: #fff;
            -webkit-text-size-adjust: 100%;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
        }

        /* 自定义样式 */
        body {
            background: linear-gradient(135deg, #0f1419 0%, #1a2332 50%, #16213e 100%);
            min-height: 100vh;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            overflow-x: hidden;
        }
        
        .dashboard-container {
            padding: 30px;
            max-width: 1400px;
            margin: 0 auto;
        }
        
        .card {
            border: none;
            border-radius: 6px;
            box-shadow: 0 8px 32px rgba(0,0,0,0.3);
            backdrop-filter: blur(20px);
            background: rgba(26, 35, 50, 0.9);
            border: 1px solid rgba(0, 255, 255, 0.1);
            margin-bottom: 25px;
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            display: flex;
            flex-direction: column;
            min-width: 0;
            word-wrap: break-word;
            overflow: hidden;
        }
        
        .card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 2px;
            background: linear-gradient(90deg, #00ffff, #0080ff, #8000ff);
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        
        .card:hover {
            transform: translateY(-4px) scale(1.01);
            box-shadow: 0 12px 40px rgba(0, 255, 255, 0.2);
            border-color: rgba(0, 255, 255, 0.3);
        }
        
        .card:hover::before {
            opacity: 1;
        }
        
        .card-header {
            background: linear-gradient(135deg, #1a2332 0%, #16213e 50%, #0f1419 100%);
            color: #00ffff;
            border-radius: 6px 6px 0 0 !important;
            font-weight: 600;
            padding: 1rem 1.5rem;
            margin-bottom: 0;
            border-bottom: 1px solid rgba(0, 255, 255, 0.2);
            position: relative;
            overflow: hidden;
        }
        
        .card-header::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(45deg, transparent 30%, rgba(0, 255, 255, 0.1) 50%, transparent 70%);
            transform: translateX(-100%);
            transition: transform 0.6s ease;
        }
        
        .card:hover .card-header::before {
            transform: translateX(100%);
        }
        
        .card-body {
            flex: 1 1 auto;
            padding: 1.5rem;
            position: relative;
        }
        
        .status-indicator {
            width: 14px;
            height: 14px;
            border-radius: 50%;
            display: inline-block;
            margin-right: 10px;
            position: relative;
            box-shadow: 0 0 10px rgba(0,0,0,0.2);
        }
        
        .status-online { 
            background: linear-gradient(45deg, #00ff88, #00ffff);
            animation: pulse 2s infinite;
        }
        
        .status-offline { 
            background: linear-gradient(45deg, #ff0066, #ff3366);
        }
        
        .status-warning { 
            background: linear-gradient(45deg, #ffaa00, #ffcc00);
            animation: pulse 1.5s infinite;
        }
        
        @keyframes pulse {
            0% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.7); }
            70% { box-shadow: 0 0 0 10px rgba(0, 255, 136, 0); }
            100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0); }
        }
        
        .data-value {
            font-size: 2rem;
            font-weight: 700;
            background: linear-gradient(135deg, #00ffff, #0080ff);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            text-shadow: 0 2px 4px rgba(0,0,0,0.3);
            margin-bottom: 5px;
        }
        
        .data-unit {
            font-size: 0.9rem;
            color: #b0b8c1;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        .chart-container {
            position: relative;
            height: 400px;
            background: rgba(26, 35, 50, 0.5);
            border-radius: 6px;
            padding: 30px;
            border: 1px solid rgba(0, 255, 255, 0.2);
            margin: 10px 0;
        }
        
        .chart-container canvas {
            width: 100% !important;
            height: 100% !important;
        }
        
        .alert-custom {
            border-radius: 10px;
            border: none;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }
        
        .navbar-brand {
            font-weight: 700;
            font-size: 1.8rem;
            background: linear-gradient(135deg, #00ffff, #0080ff);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            text-shadow: 0 2px 4px rgba(0,0,0,0.3);
            margin-right: 2rem;
        }
        
        .refresh-btn {
            background: linear-gradient(135deg, #1a2332 0%, #16213e 50%, #0f1419 100%);
            border: 1px solid rgba(0, 255, 255, 0.3);
            border-radius: 6px;
            padding: 12px 24px;
            color: #00ffff;
            font-weight: 600;
            font-size: 0.9rem;
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            cursor: pointer;
            position: relative;
            overflow: hidden;
            box-shadow: 0 4px 15px rgba(0, 255, 255, 0.2);
        }
        
        .refresh-btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(0, 255, 255, 0.2), transparent);
            transition: left 0.5s;
        }
        
        .refresh-btn:hover {
            transform: translateY(-2px) scale(1.02);
            box-shadow: 0 8px 25px rgba(0, 255, 255, 0.4);
            border-color: rgba(0, 255, 255, 0.6);
            background: linear-gradient(135deg, #16213e 0%, #1a2332 50%, #0f1419 100%);
        }
        
        .refresh-btn:hover::before {
            left: 100%;
        }
        
        .refresh-btn:active {
            transform: translateY(0) scale(1.01);
        }
        
        .data-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 20px;
        }
        
        .temperature-card {
            background: linear-gradient(135deg, #1a2332 0%, #16213e 100%);
            border-left: 3px solid #ff0066;
        }
        
        .humidity-card {
            background: linear-gradient(135deg, #1a2332 0%, #16213e 100%);
            border-left: 3px solid #00ffff;
        }
        
        .weight-card {
            background: linear-gradient(135deg, #1a2332 0%, #16213e 100%);
            border-left: 3px solid #ffaa00;
        }
        
        .energy-card {
            background: linear-gradient(135deg, #1a2332 0%, #16213e 100%);
            border-left: 3px solid #ff0066;
        }
        
        .valve-card {
            background: linear-gradient(135deg, #1a2332 0%, #16213e 100%);
            border-left: 3px solid #00ffff;
        }
        
        .car-card {
            background: linear-gradient(135deg, #0f1419 0%, #1a2332 100%);
            color: #00ffff;
            position: relative;
            overflow: hidden;
            border: 1px solid rgba(0, 255, 255, 0.2);
        }
        
        .car-card::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 100%;
            height: 100%;
            background: radial-gradient(circle, rgba(0, 255, 255, 0.05) 0%, transparent 70%);
            transform: rotate(45deg);
        }
        
        .car-card .data-value {
            background: linear-gradient(135deg, #00ffff, #0080ff);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .car-card .data-unit {
            color: rgba(0, 255, 255, 0.8);
        }

        /* Bootstrap 网格系统 */
        .row {
            --bs-gutter-x: 1.5rem;
            --bs-gutter-y: 0;
            display: flex;
            flex-wrap: wrap;
            margin-top: calc(-1 * var(--bs-gutter-y));
            margin-right: calc(-.5 * var(--bs-gutter-x));
            margin-left: calc(-.5 * var(--bs-gutter-x));
        }

        .row > * {
            flex-shrink: 0;
            width: 100%;
            max-width: 100%;
            padding-right: calc(var(--bs-gutter-x) * .5);
            padding-left: calc(var(--bs-gutter-x) * .5);
            margin-top: var(--bs-gutter-y);
        }

        .col-md-3 {
            flex: 0 0 auto;
            width: 25%;
        }

        .col-md-6 {
            flex: 0 0 auto;
            width: 50%;
        }

        .col-12 {
            flex: 0 0 auto;
            width: 100%;
        }

        /* 导航栏样式 */
        .navbar {
            position: relative;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: center;
            padding: 1rem 0;
            background: rgba(15, 20, 25, 0.8) !important;
            backdrop-filter: blur(20px);
            border-bottom: 1px solid rgba(0, 255, 255, 0.2);
        }

        .navbar-expand-lg {
            flex-wrap: nowrap;
            justify-content: center;
        }

        .navbar-dark {
            --bs-navbar-color: rgba(255, 255, 255, 0.55);
            --bs-navbar-hover-color: rgba(255, 255, 255, 0.75);
            --bs-navbar-active-color: #fff;
            --bs-navbar-disabled-color: rgba(255, 255, 255, 0.25);
            --bs-navbar-toggler-border-color: rgba(255, 255, 255, 0.1);
        }

        .container-fluid {
            width: 100%;
            padding-right: var(--bs-gutter-x, 0.75rem);
            padding-left: var(--bs-gutter-x, 0.75rem);
            margin-right: auto;
            margin-left: auto;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 2rem;
        }

        .d-flex {
            display: flex !important;
        }
        
        .navbar .d-flex {
            gap: 1rem;
        }

        .align-items-center {
            align-items: center !important;
        }

        .text-white {
            color: #00ffff !important;
        }

        .me-2 {
            margin-right: 0.5rem !important;
        }

        .me-3 {
            margin-right: 1rem !important;
        }

        .mb-2 {
            margin-bottom: 0.5rem !important;
        }

        .mb-4 {
            margin-bottom: 1.5rem !important;
        }

        .mt-2 {
            margin-top: 0.5rem !important;
        }

        .py-2 {
            padding-top: 0.5rem !important;
            padding-bottom: 0.5rem !important;
        }

        .text-center {
            text-align: center !important;
        }

        .text-muted {
            color: #b0b8c1 !important;
        }

        .w-100 {
            width: 100% !important;
        }

        .d-flex.flex-wrap {
            flex-wrap: wrap !important;
        }

        .fa-2x {
            font-size: 2em;
            transition: transform 0.3s ease;
        }
        
        .card:hover .fa-2x {
            transform: scale(1.1) rotate(5deg);
        }
        
        .fa-thermometer-half {
            color: #ff0066;
        }
        
        .fa-weight {
            color: #ffaa00;
        }
        
        .fa-bolt {
            color: #00ffff;
        }
        
        .fa-clock {
            color: #0080ff;
        }
        
        .fa-chart-pie {
            color: #00ffff;
        }
        
        .fa-chart-line {
            color: #00ffff;
        }
        
        .fa-chart-bar {
            color: #00ffff;
        }
        
        .fa-train {
            color: #00ffff;
        }

        .text-primary {
            color: #0d6efd !important;
        }

        .text-success {
            color: #198754 !important;
        }

        .text-warning {
            color: #ffc107 !important;
        }

        .text-danger {
            color: #dc3545 !important;
        }

        /* Font Awesome 图标 */
        .fas {
            -moz-osx-font-smoothing: grayscale;
            -webkit-font-smoothing: antialiased;
            display: inline-block;
            font-style: normal;
            font-variant: normal;
            text-rendering: auto;
            line-height: 1;
        }

        .fa-train:before {
            content: "\f238";
        }

        .fa-sync-alt:before {
            content: "\f2f1";
        }

        .fa-leaf:before {
            content: "\f06c";
        }

        .fa-valve:before {
            content: "\f100";
        }

        .fa-download:before {
            content: "\f019";
        }

        .fa-clock:before {
            content: "\f017";
        }

        .fa-weight:before {
            content: "\f496";
        }

        .fa-bolt:before {
            content: "\f0e7";
        }

        .fa-thermometer-half:before {
            content: "\f2c9";
        }

        .fa-chart-line:before {
            content: "\f201";
        }

        .fa-chart-bar:before {
            content: "\f080";
        }

        .fa-car:before {
            content: "\f1b9";
        }

        .fa-list-alt:before {
            content: "\f022";
        }

        .fa-info-circle:before {
            content: "\f05a";
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .col-md-3,
            .col-md-6 {
                width: 100%;
            }
            
            .data-grid {
                grid-template-columns: 1fr;
            }
            
            .refresh-btn {
                padding: 8px 15px;
                font-size: 0.9rem;
            }
            
            .dashboard-container {
                padding: 15px;
            }
            
            .card {
                margin-bottom: 15px;
            }
            
            .navbar .container-fluid {
                flex-direction: column;
                gap: 1rem;
            }
            
            .navbar-brand {
                margin-right: 0;
                margin-bottom: 0.5rem;
            }
            
            .navbar .d-flex {
                flex-wrap: wrap;
                justify-content: center;
            }
        }
        
        /* 动画效果 */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .card {
            animation: fadeInUp 0.6s ease-out;
        }
        
        .card:nth-child(1) { animation-delay: 0.1s; }
        .card:nth-child(2) { animation-delay: 0.2s; }
        .card:nth-child(3) { animation-delay: 0.3s; }
        .card:nth-child(4) { animation-delay: 0.4s; }
        
        /* 滚动条美化 */
        ::-webkit-scrollbar {
            width: 8px;
        }
        
        ::-webkit-scrollbar-track {
            background: rgba(26, 35, 50, 0.3);
            border-radius: 4px;
        }
        
        ::-webkit-scrollbar-thumb {
            background: linear-gradient(135deg, #00ffff, #0080ff);
            border-radius: 4px;
        }
        
        ::-webkit-scrollbar-thumb:hover {
            background: linear-gradient(135deg, #0080ff, #8000ff);
        }
        
        /* 系统日志样式 */
        #system-log {
            background: rgba(26, 35, 50, 0.3);
            border-radius: 6px;
            padding: 15px;
            border: 1px solid rgba(0, 255, 255, 0.1);
        }
        
        #system-log .alert {
            border-radius: 6px;
            border: none;
            margin-bottom: 8px;
            padding: 10px 15px;
            background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 128, 255, 0.1));
            backdrop-filter: blur(10px);
            color: #b0b8c1;
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark" style="background: rgba(0,0,0,0.2); backdrop-filter: blur(10px);">
        <div class="container-fluid">
            <a class="navbar-brand" href="#">
                <i class="fas fa-train me-2"></i>列车数据监测系统
            </a>
            <div class="d-flex align-items-center">
                <span class="status-indicator status-online me-2"></span>
                <span class="text-white me-3">系统在线</span>
                <button class="refresh-btn me-2" onclick="refreshData()">
                    <i class="fas fa-sync-alt me-2"></i>刷新数据
                </button>
                <button class="refresh-btn me-2" onclick="toggleEnergySaving()">
                    <i class="fas fa-leaf me-2"></i>节能模式
                </button>
                <button class="refresh-btn me-2" onclick="resetValves()">
                    <i class="fas fa-valve me-2"></i>重置阀门
                </button>
                <button class="refresh-btn" onclick="exportData()">
                    <i class="fas fa-download me-2"></i>导出数据
                </button>
            </div>
        </div>
    </nav>

    <div class="dashboard-container">
        <!-- 公共数据概览 -->
        <div class="row mb-4">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <i class="fas fa-chart-pie me-2"></i>系统公共数据
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-3">
                                <div class="text-center">
                                    <i class="fas fa-clock fa-2x text-primary mb-2"></i>
                                    <div class="data-value" id="current-time">--:--:--</div>
                                    <div class="data-unit">当前时间</div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="text-center">
                                    <i class="fas fa-weight fa-2x text-success mb-2"></i>
                                    <div class="data-value" id="total-weight">0</div>
                                    <div class="data-unit">总重量 (kg)</div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="text-center">
                                    <i class="fas fa-leaf fa-2x text-warning mb-2"></i>
                                    <div class="data-value" id="energy-saving">否</div>
                                    <div class="data-unit">节能模式</div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="text-center">
                                    <i class="fas fa-bolt fa-2x text-danger mb-2"></i>
                                    <div class="data-value" id="total-consumption">0.0</div>
                                    <div class="data-unit">总能耗 (kW·h)</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 温度趋势图表 -->
        <div class="row mb-4">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <i class="fas fa-chart-line me-2"></i>温度趋势分析
                    </div>
                    <div class="card-body">
                        <div class="chart-container">
                            <canvas id="temperatureChart"></canvas>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 能耗分析图表 -->
        <div class="row mb-4">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <i class="fas fa-chart-bar me-2"></i>能耗分析
                    </div>
                    <div class="card-body">
                        <div class="chart-container">
                            <canvas id="energyChart"></canvas>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 环境监测 -->
        <div class="row mb-4">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <i class="fas fa-leaf me-2"></i>环境监测数据
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-3">
                                <div class="text-center">
                                    <div class="data-value" id="outdoor-temp">--</div>
                                    <div class="data-unit">室外温度 (°C)</div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="text-center">
                                    <div class="data-value" id="pm25">--</div>
                                    <div class="data-unit">PM2.5 (μg/m³)</div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="text-center">
                                    <div class="data-value" id="pmtovc">--</div>
                                    <div class="data-unit">PMTOVC (μg/m³)</div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="text-center">
                                    <div class="data-value" id="co2">--</div>
                                    <div class="data-unit">CO₂ (ppm)</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 列车分布数据 -->
        <div class="row mb-4">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <i class="fas fa-train me-2"></i>列车分布数据
                    </div>
                    <div class="card-body">
                        <div class="data-grid">
                            <!-- A1车厢 -->
                            <div class="card car-card">
                                <div class="card-body">
                                    <h6 class="card-title"><i class="fas fa-thermometer-half me-2"></i>A1车厢</h6>
                                    <div class="row">
                                        <div class="col-6">
                                            <div class="data-value" id="a1-temp">--</div>
                                            <div class="data-unit">温度 (°C)</div>
                                        </div>
                                        <div class="col-6">
                                            <div class="data-value" id="a1-humi">--</div>
                                            <div class="data-unit">湿度 (%)</div>
                                        </div>
                                    </div>
                                    <div class="mt-2">
                                        <small style="color: rgba(255,255,255,0.8);">重量: <span id="a1-weight">0</span> kg</small>
                                    </div>
                                </div>
                            </div>

                            <!-- B1车厢 -->
                            <div class="card car-card">
                                <div class="card-body">
                                    <h6 class="card-title"><i class="fas fa-thermometer-half me-2"></i>B1车厢</h6>
                                    <div class="row">
                                        <div class="col-6">
                                            <div class="data-value" id="b1-temp">--</div>
                                            <div class="data-unit">温度 (°C)</div>
                                        </div>
                                        <div class="col-6">
                                            <div class="data-value" id="b1-humi">--</div>
                                            <div class="data-unit">湿度 (%)</div>
                                        </div>
                                    </div>
                                    <div class="mt-2">
                                        <small style="color: rgba(255,255,255,0.8);">重量: <span id="b1-weight">0</span> kg</small>
                                    </div>
                                </div>
                            </div>

                            <!-- B2车厢 -->
                            <div class="card car-card">
                                <div class="card-body">
                                    <h6 class="card-title"><i class="fas fa-thermometer-half me-2"></i>B2车厢</h6>
                                    <div class="row">
                                        <div class="col-6">
                                            <div class="data-value" id="b2-temp">--</div>
                                            <div class="data-unit">温度 (°C)</div>
                                        </div>
                                        <div class="col-6">
                                            <div class="data-value" id="b2-humi">--</div>
                                            <div class="data-unit">湿度 (%)</div>
                                        </div>
                                    </div>
                                    <div class="mt-2">
                                        <small style="color: rgba(255,255,255,0.8);">重量: <span id="b2-weight">0</span> kg</small>
                                    </div>
                                </div>
                            </div>

                            <!-- A2车厢 -->
                            <div class="card car-card">
                                <div class="card-body">
                                    <h6 class="card-title"><i class="fas fa-thermometer-half me-2"></i>A2车厢</h6>
                                    <div class="row">
                                        <div class="col-6">
                                            <div class="data-value" id="a2-temp">--</div>
                                            <div class="data-unit">温度 (°C)</div>
                                        </div>
                                        <div class="col-6">
                                            <div class="data-value" id="a2-humi">--</div>
                                            <div class="data-unit">湿度 (%)</div>
                                        </div>
                                    </div>
                                    <div class="mt-2">
                                        <small style="color: rgba(255,255,255,0.8);">重量: <span id="a2-weight">0</span> kg</small>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 环境监测 -->
        <div class="row mb-4">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <i class="fas fa-leaf me-2"></i>环境监测数据
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-3">
                                <div class="text-center">
                                    <div class="data-value" id="outdoor-temp">--</div>
                                    <div class="data-unit">室外温度 (°C)</div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="text-center">
                                    <div class="data-value" id="pm25">--</div>
                                    <div class="data-unit">PM2.5 (μg/m³)</div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="text-center">
                                    <div class="data-value" id="pmtovc">--</div>
                                    <div class="data-unit">PMTOVC (μg/m³)</div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="text-center">
                                    <div class="data-value" id="co2">--</div>
                                    <div class="data-unit">CO₂ (ppm)</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 阀门状态 -->
        <div class="row mb-4">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <i class="fas fa-valve me-2"></i>阀门状态监控
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-3">
                                <h6 style="color: #00ffff;">A1车厢阀门</h6>
                                <div id="a1-valves" class="d-flex flex-wrap"></div>
                            </div>
                            <div class="col-md-3">
                                <h6 style="color: #00ffff;">B1车厢阀门</h6>
                                <div id="b1-valves" class="d-flex flex-wrap"></div>
                            </div>
                            <div class="col-md-3">
                                <h6 style="color: #00ffff;">B2车厢阀门</h6>
                                <div id="b2-valves" class="d-flex flex-wrap"></div>
                            </div>
                            <div class="col-md-3">
                                <h6 style="color: #00ffff;">A2车厢阀门</h6>
                                <div id="a2-valves" class="d-flex flex-wrap"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 系统日志 -->
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <i class="fas fa-list-alt me-2"></i>系统日志
                    </div>
                    <div class="card-body">
                        <div id="system-log" style="max-height: 300px; overflow-y: auto;">
                            <!-- 日志内容将在这里动态添加 -->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="script.js"></script>
    <script>
        // 简化的Chart.js实现
        class Chart {
            constructor(ctx, config) {
                this.ctx = ctx;
                this.config = config;
                this.data = config.data;
                this.options = config.options;
                this.init();
            }
            
            init() {
                this.canvas = this.ctx.canvas;
                this.width = this.canvas.width;
                this.height = this.canvas.height;
                this.draw();
            }
            
            draw() {
                const ctx = this.ctx;
                ctx.clearRect(0, 0, this.width, this.height);
                
                if (this.config.type === 'line') {
                    this.drawLineChart();
                } else if (this.config.type === 'bar') {
                    this.drawBarChart();
                }
            }
            
            drawLineChart() {
                const ctx = this.ctx;
                const datasets = this.data.datasets;
                const labels = this.data.labels;
                
                if (!labels || labels.length === 0) return;
                
                const padding = 40;
                const chartWidth = this.width - 2 * padding;
                const chartHeight = this.height - 2 * padding;
                const stepX = chartWidth / (labels.length - 1);
                
                // 计算数据范围
                let minY = Infinity, maxY = -Infinity;
                datasets.forEach(dataset => {
                    dataset.data.forEach(value => {
                        if (value < minY) minY = value;
                        if (value > maxY) maxY = value;
                    });
                });
                
                const rangeY = maxY - minY || 1;
                
                // 绘制网格
                ctx.strokeStyle = '#e0e0e0';
                ctx.lineWidth = 1;
                for (let i = 0; i <= 5; i++) {
                    const y = padding + (i * chartHeight / 5);
                    ctx.beginPath();
                    ctx.moveTo(padding, y);
                    ctx.lineTo(this.width - padding, y);
                    ctx.stroke();
                }
                
                // 绘制数据线
                datasets.forEach((dataset, datasetIndex) => {
                    ctx.strokeStyle = dataset.borderColor;
                    ctx.lineWidth = 2;
                    ctx.beginPath();
                    
                    dataset.data.forEach((value, index) => {
                        const x = padding + index * stepX;
                        const y = padding + chartHeight - ((value - minY) / rangeY) * chartHeight;
                        
                        if (index === 0) {
                            ctx.moveTo(x, y);
                        } else {
                            ctx.lineTo(x, y);
                        }
                    });
                    
                    ctx.stroke();
                });
                
                // 绘制标签
                ctx.fillStyle = '#666';
                ctx.font = '12px Arial';
                ctx.textAlign = 'center';
                labels.forEach((label, index) => {
                    const x = padding + index * stepX;
                    const y = this.height - 10;
                    ctx.fillText(label, x, y);
                });
            }
            
            drawBarChart() {
                const ctx = this.ctx;
                const datasets = this.data.datasets;
                const labels = this.data.labels;
                
                if (!labels || labels.length === 0) return;
                
                const padding = 60;
                const chartWidth = this.width - 2 * padding;
                const chartHeight = this.height - 2 * padding;
                const barWidth = chartWidth / labels.length * 0.8;
                const barSpacing = chartWidth / labels.length * 0.2;
                
                // 计算数据范围
                let maxY = 0;
                datasets.forEach(dataset => {
                    dataset.data.forEach(value => {
                        if (value > maxY) maxY = value;
                    });
                });
                
                // 绘制网格
                ctx.strokeStyle = '#e0e0e0';
                ctx.lineWidth = 1;
                for (let i = 0; i <= 5; i++) {
                    const y = padding + (i * chartHeight / 5);
                    ctx.beginPath();
                    ctx.moveTo(padding, y);
                    ctx.lineTo(this.width - padding, y);
                    ctx.stroke();
                }
                
                // 绘制柱状图
                datasets.forEach(dataset => {
                    dataset.data.forEach((value, index) => {
                        const x = padding + index * (barWidth + barSpacing) + barSpacing / 2;
                        const barHeight = (value / maxY) * chartHeight;
                        const y = padding + chartHeight - barHeight;
                        
                        ctx.fillStyle = dataset.backgroundColor[index] || dataset.backgroundColor;
                        ctx.fillRect(x, y, barWidth, barHeight);
                        
                        // 绘制数值
                        ctx.fillStyle = '#333';
                        ctx.font = '12px Arial';
                        ctx.textAlign = 'center';
                        ctx.fillText(value.toFixed(1), x + barWidth / 2, y - 5);
                    });
                });
                
                // 绘制标签
                ctx.fillStyle = '#666';
                ctx.font = '12px Arial';
                ctx.textAlign = 'center';
                labels.forEach((label, index) => {
                    const x = padding + index * (barWidth + barSpacing) + barSpacing / 2 + barWidth / 2;
                    const y = this.height - 10;
                    ctx.fillText(label, x, y);
                });
            }
            
            update() {
                this.draw();
            }
        }
    </script>
</body>
</html> 